package com.njworkorder.Controller;

import com.njworkorder.Service.VideoPlatformService;
import com.njworkorder.VO.VideoPlatformVo.VideoPlatVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "视频平台api")
@RestController
@RequestMapping("/videoPlatform")
public class VideoPlatformController {

    private final VideoPlatformService videoPlatformService;
    public VideoPlatformController(VideoPlatformService videoPlatformService){
        this.videoPlatformService = videoPlatformService;
    }

    @Operation(summary = "token信息获取")
    @GetMapping("getAccessToken")
    public VideoPlatVo getAccessToken() {
        return videoPlatformService.getAccessToken("accessToken");
    }

    @Operation(summary = "获取摄像机分页")
    @GetMapping("getVideoPage")
    public VideoPlatVo getVideoPage(@Schema(description = "起始页") @RequestParam("currPage") String currPage,
                                    @Schema(description = "页数") @RequestParam("pageSize") String pageSize) {
        return videoPlatformService.getVideoPage(currPage, pageSize).block();
    }

    @Operation(summary = "视频播放地址获取")
    @GetMapping("getCameraPlayURL")
    public VideoPlatVo getCameraPlayURL(@Schema(description = "摄像机id") @RequestParam("id") String id,
                                        @Schema(description = "视频格式") @RequestParam("videoFormat") String videoFormat,
                                        @Schema(description = "视频码流") @RequestParam("videoRate") String videoRate) {
        return videoPlatformService.getCameraPlayURL(id, videoFormat, videoRate).block();
    }



}
